#-*-coding:utf-8-*-
import hou
class Handles(object):
    def __init__(self):
        super(Handles,self).__init__()

    def setHideLockedHandleParts(self,bool):
        if bool == True:
            hou.setPreference('handles.hidelockedparts.val','1')
            # print('1')
        else:
            hou.setPreference('handles.hidelockedparts.val','0')
            # print('0')

    def getHideLockedHandleParts(self):
        return hou.getPreference('handles.hidelockedparts.val')
        # print('getHideLockedHandleParts')


    def setColorTransformHandlesByAxis(self,bool):
        if bool == True:
            hou.setPreference('handles.colorxform.val','1')
            # print('1')
        else:
            hou.setPreference('handles.colorxform.val','0')
            # print('0')

    def getColorTransformHandlesByAxis(self):
        return hou.getPreference('handles.colorxform.val')
        # print('getColorTransformHandlesByAxis')


    def setKeepHandleAlignmentWhenReslecting(self,bool):
        if bool == True:
            hou.setPreference('handles.keepalign.val','1')
            # print('1')
        else:
            hou.setPreference('handles.keepalign.val','0')
            # print('0')

    def getKeepHandleAlignmentWhenReslecting(self):
        return hou.getPreference('handles.keepalign.val')
        # print('getKeepHandleAlignmentWhenReslecting')


    def setDefaultHandleAlignment(self,handleNum):
        '''
        :param handleNum: 0 - Object, 1 - World, 2 - View,3 - Parent Object,
        4 - Component,5 - C-Plane
        :return:
        '''
        hou.setPreference('handles.defaultworldalign.val', str(handleNum))
        # print('setDefaultHandleAlignment')


    def getDefaultHandleAlignment(self):
        hou.getPreference('handles.defaultworldalign.val')
        # print('getDefaultHandleAlignment')



    def setAddToChannelListWhenSettingKeyframes(self,channelNum):
        '''
        :param channelNum: 0 - Do not Modify Channel List,
        1 - Add to Channel List,
        2 - Isolate in Channel
        :return:
        '''
        hou.setPreference('handles.scope.val',str(channelNum))
        # print('setAddToChannelListWhenSettingKeyframes')


    def getAddToChannelListWhenSettingKeyframes(self):
        return hou.getPreference('handles.scope.val')
        # print('getAddToChannelListWhenSettingKeyframes')



    def setOpenAnimationEditorIfClosedWhenAddingChannelsFromHandles(self,bool):
        if bool == True:
            hou.setPreference('handles.openchanneleditor.val','1')
            # print('1')
        else:
            hou.setPreference('handles.openchanneleditor.val','0')
            # print('0')

    def getOpenAnimationEditorIfClosedWhenAddingChannelsFromHandles(self):
        return hou.setPreference('handles.openchanneleditor.val')
        # print('getOpenAnimationEditorIfClosedWhenAddingChannelsFromHandles')


    def setHandleScale(self,value):
        hou.setPreference('handles.scale.val', str(value))
        # print('setHandleScale')

    def getHandleScale(self):
        return hou.getPreference('handles.scale.val')
        # print('getHandleScale')


    def setPickDistance(self,value):
        hou.setPreference('handles.pickdistance.val', str(value))
        # print('setPickDistance')

    def getPickDistance(self):
        hou.getPreference('handles.pickdistance.val')
        # print('getPickDistance')


    def setOrientToNormal(self,axis):
        '''
        :param axis: 0 - Y,1 - Z, 2 - Up
        :return:
        '''
        if axis==0:
            hou.setPreference('handles.axistoorienttonormal.val', 'Y')
            # print('Y')
        elif axis==1:
            hou.setPreference('handles.axistoorienttonormal.val', 'Z')
            # print('Z')
        elif axis==2:
            hou.setPreference('handles.axistoorienttonormal.val', 'Up')
            # print('Up')

    def getOrientToNormal(self):
        return hou.getPreference('handles.axistoorienttonormal.val')
        # print('getOrientToNormal')


    def setShowNegativeAxesForTranslateHandles(self,bool):
        if bool == True:
            hou.setPreference('handles.extendedaxes.val','1')
            # print('1')
        else:
            hou.setPreference('handles.extendedaxes.val','0')
            # print('0')

    def getShowNegativeAxesForTranslateHandles(self):
        return hou.getPreference('handles.extendedaxes.val')
        # print('setShowNegativeAxesForTranslateHandles')



    def setShowPlanarDraggingTargetsForTranslateHandles(self,bool):
        if bool == True:
            hou.setPreference('handles.planartranslatetargets.val','1')
            # print('1')
        else:
            hou.setPreference('handles.planartranslatetargets.val','0')
            # print('0')

    def getShowPlanarDraggingTargetsForTranslateHandles(self):
        return hou.getPreference('handles.planartranslatetargets.val')
        # print('getShowPlanarDraggingTargetsForTranslateHandles')


    def setAllowPlanarDraggingOfTranslateHandlesBetweenAxes(self,bool):
        if bool == True:
            hou.setPreference('handles.translateinside.val','1')
            # print('1')
        else:
            hou.setPreference('handles.translateinside.val','0')
            # print('0')

    def getAllowPlanarDraggingOfTranslateHandlesBetweenAxes(self):
        return hou.getPreference('handles.translateinside.val')
        # print('getAllowPlanarDraggingOfTranslateHandlesBetweenAxes')



    def setPreferPlanarDraggingBetweenAxesOverBackFacingAxes(self,bool):

        if bool == True:
            hou.setPreference('handles.translateinsideobscuresbackaxes.val', '1')
            # print('1')
        else:
            hou.setPreference('handles.translateinsideobscuresbackaxes.val', '0')
            # print('0')

    def getPreferPlanarDraggingBetweenAxesOverBackFacingAxes(self):
        return hou.getPreference('handles.translateinsideobscuresbackaxes.val')
        # print('getPreferPlanarDraggingBetweenAxesOverBackFacingAxes')



    def setAllowDraggingOfRotateHandlesBetweenRings(self,bool):
        if bool == True:
            hou.setPreference('handles.tumbleinside.val','1')
            # print('1')
        else:
            hou.setPreference('handles.tumbleinside.val','0')
            # print('0')

    def getAllowDraggingOfRotateHandlesBetweenRings(self):
        return  hou.getPreference('handles.tumbleinside.val')
        # print('getAllowDraggingOfRotateHandlesBetweenRings')


    def setAllowIndirectHandleDraggingWithMMB(self,bool):
        if bool == True:
            hou.setPreference('handles.indirectdrag.val','1')
            # print('1')
        else:
            hou.setPreference('handles.indirectdrag.val','0')
            # print('0')

    def getAllowIndirectHandleDraggingWithMMB(self):
        return hou.getPreference('handles.indirectdrag.val')
        # print('getAllowIndirectHandleDraggingWithMMB')


    def setTranslateHandle(self,handleNum):
        '''
        :param handleNum: 0 - Map Drag to Axis, 1 - Map Drap to Construction Plane,
        2 - Drag in View Plane
        :return:
        '''
        hou.setPreference('handles.indirectdragtranslatemethod.val',str(handleNum))
        # print('setTranslateHandle')

    def getTranslateHandle(self):
        return hou.getPreference('handles.indirectdragtranslatemethod.val')
        # print('getTranslateHandle')


    def setSpiderHandle(self,handleNum):
        '''
        :param handleNum: 0 - Map Drag to Axis, 1 - Map Drap to Construction Plane,
        2 - Drag in View Plane
        :return:
        '''

        hou.setPreference('handles.indirectdragspidermethod.val',str(handleNum))
        # print('setSpiderHandle')


    def getSpiderHandle(self):
        return hou.getPreference('handles.indirectdragspidermethod.val')
        # print('getSpiderHandle')



    def setPreferIndirectTranslateOverIndirectRotate(self,bool):
        if bool == True:
            hou.setPreference('handles.indirectdragprefertranslateoverrotate.val','1')
            # print('1')
        else:
            hou.setPreference('handles.indirectdragprefertranslateoverrotate.val','0')
            # print('0')


    def getPreferIndirectTranslateOverIndirectRotate(self):
        return hou.getPreference('handles.indirectdragprefertranslateoverrotate.val')
        # print('getPreferIndirectTranslateOverIndirectRotate')


    def setPreferIndirectTranslateOverIndirectVectorRotate(self,bool):

        if bool == True:
            hou.setPreference('handles.indirectdragprefertranslateovervrotate.val', '1')
            # print('1')
        else:
            hou.setPreference('handles.indirectdragprefertranslateovervrotate.val', '0')
            # print('0')


    def getPreferIndirectTranslateOverIndirectVectorRotate(self):
        return hou.getPreference('handles.indirectdragprefertranslateovervrotate.val')
        # print('getPreferIndirectTranslateOverIndirectVectorRotate')



    def setPreferIndirectTranslateOverIndirectScale(self,bool):
        if bool == True:
            hou.setPreference('handles.indirectdragprefertranslateoverscale.val','1')
            # print('1')
        else:
            hou.setPreference('handles.indirectdragprefertranslateoverscale.val','0')
            # print('0')


    def getPreferIndirectTranslateOverIndirectScale(self):
        return hou.getPreference('handles.indirectdragprefertranslateoverscale.val')
        # print('getPreferIndirectTranslateOverIndirectScale')




    def setHideRotateHandleRingsParallelToTheViewDirection(self,bool):
        if bool == True:
            hou.setPreference('handles.useviewdirtohiderotaterings.val','1')
            # print('1')
        else:
            hou.setPreference('handles.useviewdirtohiderotaterings.val','0')
            # print('0')


    def getHideRotateHandleRingsParallelToTheViewDirection(self):
        return hou.getPreference('handles.useviewdirtohiderotaterings.val')
        # print('getHideRotateHandleRingsParallelToTheViewDirection')



    def setShowViewAxisRingForRotateHandles(self,bool):
        if bool == True:
            hou.setPreference('handles.viewaxisrotatering.val','1')
            # print('1')
        else:
            hou.setPreference('handles.viewaxisrotatering.val','0')
            # print('0')

    def getShowViewAxisRingForRotateHandles(self):
        return hou.getPreference('handles.viewaxisrotatering.val')
        # print('getShowViewAxisRingForRotateHandles')



    def setDefaultTransformHandlesToGimbalMode(self,bool):
        if bool == True:
            hou.setPreference('handles.defaultgimbal.val','1')
            # print('1')
        else:
            hou.setPreference('handles.defaultgimbal.val','0')
            # print('0')

    def getDefaultTransformHandlesToGimbalMode(self):
        return hou.getPreference('handles.defaultgimbal.val')
        # print('getDefaultTransformHandlesToGimbalMode')


    def setDefault2DOrientationHandlesTransformIsGlobal(self,bool):
        if bool == True:
            hou.setPreference('handles.defaultxformglobal.val','1')
            # print('1')
        else:
            hou.setPreference('handles.defaultxformglobal.val','0')
            # print('0')

    def getDefault2DOrientationHandlesTransformIsGlobal(self):
        return hou.getPreference('handles.defaultxformglobal.val')
        # print('getDefault2DOrientationHandlesTransformIsGlobal')




    def setScaleHandleStyle(self,styleNum):
        '''
        :param styleNum: 0 - Cloverleaf,
        1 - Axis
        :return:
        '''
        hou.setPreference('handles.scalehandlestyle.val',str(styleNum))
        # print('setScaleHandleStyle')

    def getScaleHandleStyle(self):
        return hou.getPreference('handles.scalehandlestyle.val')
        # print('getScaleHandleStyle')


